<include file="../Public/_top" />
<script type="text/javascript" src="__THEME__/js/rcalendar.js"></script>
<style>
  #rcalendar {
    font: 14px Microsoft YaHei, SimSun, Arial !important
  }
</style>
<div class="content">
  <div class="wrap">
    <include file="./_left" />
    <div class="con_main">
      <div class="con_tit">修改学生信息</div>
      <div class="con_box">
        <table style="width:320px;">
          <tr height="50">
            <td>姓名：</td>
            <td><input type="text" id="stu_name" value="{$data.stu_name}" style="height:25px;"></td>
          </tr>
          <tr height="50">
            <td>性别：</td>
            <td>
              <input type="radio" name="gender" value="1" <if condition="$data['gender'] eq 1">checked="checked"</if>> 男
              <input type="radio" name="gender" value="2" <if condition="$data['gender'] eq 2">checked="checked"</if>> 女
            </td>
          </tr>
          <tr height="50">
            <td>生产方式：</td>
            <td>
              <input type="radio" name="birth_condition" value="1" <if condition="$data['birth_condition'] eq 1">checked="checked"</if>> 顺产
              <input type="radio" name="birth_condition" value="2" <if condition="$data['birth_condition'] eq 2">checked="checked"</if>> 剖腹产
            </td>
          </tr>
          <tr height="50">
            <td>出生时间：</td>
            <td><input type="text" id="birthday" value="{$data.birthday}" style="height:25px;" onFocus="rcalendar(this,'');"> 示例：2016-01-01</td>
          </tr>
          <tr height="50">
            <td>出生体重：</td>
            <td><input type="text" id="birth_weight" value="{$data.birth_weight}" style="height:25px;"> /kg</td>
          </tr>
          <tr height="50">
            <td>入园时间：</td>
            <td><input type="text" id="into_campus_time" value="{$data.into_campus_time}" style="height:25px;" onFocus="rcalendar(this,'');">示例：2019-09-01</td>
          </tr>
        </table>
      </div>
      <div class="action_link tc small" style="border:0;">
        <input type="hidden" id="id" value="{$data.stu_id}">
        <input type="hidden" id="class_id" value="{$data.class_id}">
        <a class="save" href="javascript:saveStudent();">确定</a>
        <a href="#">取消</a>
      </div>
    </div>
  </div>
</div>
<script>
  function saveStudent() {
    var StuName = "{$params['stuName']}";
    var Grade = "{$params['grade']}";
    var Class = "{$params['class']}";

    var id = $("#id").val();
    var stu_name = $("#stu_name").val();
    var birthday = $("#birthday").val();
    var birth_weight = $("#birth_weight").val();
    var class_id = $("#class_id").val();
    var into_campus_time = $("#into_campus_time").val();
    var gender = $('input[name="gender"]:checked ').val();
    var birth_condition = $('input[name="birth_condition"]:checked ').val();
    if (stu_name == "") {
      alert("请输入学生姓名");
      return;
    }
    if (birthday == "") {
      alert("请输入学生出生时间");
      return;
    }
    if (birth_weight == "") {
      alert("请输入学生出生体重");
      return;
    }
    if (into_campus_time == "") {
      alert("请输入入园时间");
      return;
    }
    $.ajax({
      type: "POST",
      url: "{:U('public/Index/doSaveStudent')}",
      data: "stu_name=" + stu_name + "&birth_weight=" + birth_weight + "&into_campus_time=" + into_campus_time + "&gender=" + gender + "&birth_condition=" + birth_condition + "&id=" + id + "&class_id=" + class_id + "&birthday=" + birthday,
      dataType: "text",
      success: function (data) {
        if (isNaN(data)) {
          alert(data);
        } else {
          window.location.href = document.referrer + "&grade=" + Grade + "&class=" + Class + "&stuName=" + StuName;
        }
      }
    });
  }
</script>
<include file="../Public/_foot" />